package cn.dinghu.pro.utils;

/**
 * @author 熙宝
 * @create 2024-12-12-8:58
 */

import java.util.List;

/**
 * 分页工具类
 * @param <T>
 */
public class Pager<T> {
    private int pageSize;// 每页显示条数
    private int pageNo;// 当前页码
    private int totalCount;// 总条数
    private int totalPageCount;// 总页数
    private List<T> dataList;// 当前页数据集合

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        if (totalCount > 0){
            this.totalCount = totalCount;
            totalPageCount = this.totalCount % pageSize == 0 ?
                    (this.totalCount / pageSize) :
                    (this.totalCount / pageSize + 1);
        }
    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;

    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }
}
